package cn.ly817.jay.enums;

/**
 * Created by LuoYu on 2016/12/2.
 */
public enum MissionGrade {
    C(1,4),
    B(2,8),
    A(3,16)
    ;
    private int dbGrade;

    private int score;

    MissionGrade(int dbGrade, int score) {
        this.dbGrade = dbGrade;
        this.score = score;
    }

    public int getDbGrade() {
        return dbGrade;
    }

    public int getScore() {
        return score;
    }


    /**
     * 通过数据库中的等级，在字典表中获取等级对应的分数
     */
    public static Integer scoreOf(int dbGrade){
        for (MissionGrade state : values()){
            if (state.getDbGrade() == dbGrade)
                return state.getScore();
        }
        return null;
    }

    public static MissionGrade stateOf(int dbGrade){
        for (MissionGrade state : values()){
            if (state.getDbGrade() == dbGrade)
                return state;
        }
        return null;
    }

}

